/**
 * 定义小时数据模块
 */
(function(window, angular, undefined){
	var module = angular.module('water.apps.ws.dataMonitor.reportHistory.reportHourDataManager', ['water.apps.common.report.reportBase',
	                                                                                  'water.common.dateUtil']);
	
	module.controller('reportHourDataManagerController',function($rootScope,$scope,$controller,$dateUtil,$waterDataCommon){

		var control = $controller("commonReportController",{$scope:$scope});
		
		$scope.dataAPIName = "hourListGetter";
		$scope.dataExportAPIName = "exportHourExcel";
		/**
		 * 开始时间
		 */
		$scope.startDate;
		/**
		 * 结束时间
		 */
		$scope.endDate;
		/**
		 * 获取查询参数
		 */
		$scope.getQueryObject = function(){
			var nowdate = new Date();
			var nd=nowdate.getFullYear()+"-"+(nowdate.getMonth()+1)+"-"+nowdate.getDate();
			var selectdate=new Date($scope.endDate);
			var lastdate=new Date(nd);
			var endHour;
			if(  selectdate.getTime() >= lastdate.getTime() ){
				endHour=nowdate.getHours()+":"+nowdate.getMinutes()+":"+nowdate.getSeconds();
			}
			else{
				endHour=" 23:59:59"; 
			}
			
			var parmsStr = $scope.selectedModel.parmToChecksStr;
			var queryObject = {
					"MN":$scope.selectedModel.MN,
					"PARMS":parmsStr,
					"START":$scope.startDate + " 00:00:00",
					"END":$scope.endDate +" "+endHour
				};
			return queryObject;
		}
		
		/**
		 * 初始化
		 */
		function _init(){
			var endDate = new Date();
			var startDate = $dateUtil.addDay(endDate,-1)
			$scope.startDate = $dateUtil.formatDate(startDate,'yyyy-MM-dd');
			$scope.endDate = $dateUtil.formatDate(endDate,'yyyy-MM-dd');
		}
		
		_init();
		
	});
}(window, angular));	